import { LayerEventType, OverlayEventType } from '../../src/event/EventType.js';
import Tileset from '../../src/overlay/model/Tileset.js';
import TilesetLayer from '../../src/layer/TilesetLayer.js';
import PrimitiveSource from '../../src/data/source/vector/PrimitiveSource.js';

/**
 * 添加3DTiles图层
 */
 export function add_tileset_layer(earth){
    
    let source = new PrimitiveSource("tileset");

    let layer = new TilesetLayer("baisha", {
        source : source
    });
    layer.on(LayerEventType.ADD, evt=>{
        console.log(evt.obj.name);
    })

    earth.addLayer(layer);

    let tileset = new Tileset(
        //"/tileset/baisha/tileset.json",{}
        //"/tileset/3dtiles/tanghezhen/tileset.json",{}
        'http://earthsdk.com/v/last/Apps/assets/dayanta/tileset.json',
        {
            show: true,
            backFaceCulling: true,
        }
    );

    tileset.on(OverlayEventType.ADD, evt=>{
        console.log(evt.obj.id);
    });


    layer.addOverlay(tileset);
    
    earth.flyTo(tileset);
    
    //删除overlay
    //layer.removeOverlay(tileset);
}
